package org.seedltd.upms.controller.sys;

import lombok.AllArgsConstructor;
import org.seedltd.springsecurity.SeedltdUserDetails;
import org.seedltd.springsecurity.utils.UserUtils;
import org.seedltd.upms.model.sys.vo.UserMenuVO;
import org.seedltd.upms.service.sys.SysMenuService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 首页控制器
 *
 * @author laizuan
 * @version 1.0
 * @since 2021/6/23 15:52
 */
@RestController
@AllArgsConstructor
@RequestMapping("/index")
public class IndexController {

    private final SysMenuService sysMenuService;

    /**
     * 获取当前登入用户
     *
     * @return 当前登入用
     */
    @GetMapping("/curruser")
    public SeedltdUserDetails currentIndex() {
        return UserUtils.getLoginUser();
    }


    @GetMapping("/user/menu")
    public List<UserMenuVO> userMenu() {
        return sysMenuService.listUserMenu();
    }
}
